package phone.example.com.a36kr.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.content.ContextCompat;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ImageSpan;

import java.util.ArrayList;

import phone.example.com.a36kr.R;

/**
 * Created by dllo on 16/8/15.
 * tabLayout + viewPager
 */
public class ViewPagerAdapter extends FragmentPagerAdapter{

    private ArrayList<Fragment> fragments;
    private ArrayList<String> list = new ArrayList<>();



    public void setFragments(ArrayList<Fragment> fragments) {
        this.fragments = fragments;
        list.add("新闻");
        list.add("股权投资");
        list.add("发现");
        list.add("我的");
    }

    public ViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments == null ? 0 : fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return list.get(position);
    }
}
